home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
The Fatted Calf
/
The Fatted Calf.iso
/
Applications
/
Games
/
Solitaire
/
Sources
/
Klondike
/
DiscardPileDelegate.m
< prev
next >
Wrap
Text File
|
1994-01-12
|
2KB
|
119 lines
/* indent:4 tabsize:8 font:fixed-width */
#import "DiscardPileDelegate.h"
#import "SuitPileDelegate.h"
#import "../Solitaire/Solitaire.h"
#import "Klondike.h"
@implementation DiscardPileDelegate
- setDrawCardCount:(int)theCount
{
maxIndex = theCount;
return self;
}
- setSuitCardPileViews:(id [])theViews
{
int i;
for (i=0; i<4; i++)
suitCardPileViews[i] = *(theViews + i);
return self;
}
- doubleClickedCard:aCard in:aCardPileView
{
int i;
id tempCard;
id cardPile = [aCardPileView cardPile];
if ((aCard == [cardPile cardAt:CS_TOP] ) && (![aCard isFaceUp]))
{
[aCard flip];
[aCardPileView display];
}
else if (aCard == [cardPile cardAt:CS_TOP])
{
for (i=0;i<4;i++)
{
[[suitCardPileViews[i] delegate] setDoubleClickCheck];
if ([[suitCardPileViews[i] delegate] canAcceptPile:cardPile
from:aCardPileView
in:suitCardPileViews[i]])
{
[[suitCardPileViews[i] cardPile] addCard:[cardPile
cardAt:CS_TOP]];
[cardPile removeCard:[cardPile cardAt:CS_TOP]];
if (tempCard = [recycleCardPile cardAt:CS_TOP])
{
[recycleCardPile removeCard:tempCard];
[cardPile insertCard:tempCard at:CS_BOTTOM];
}
[aCardPileView display];
[suitCardPileViews[i] display];
[SolGameController() checkForWin];
break;
}
}
}
return self;
}
- (BOOL)draggedPile:aCardPile from:discardCardPileView
{
id discardCardPile = [discardCardPileView cardPile];
if (([aCardPile cardAt:CS_TOP]) == ([discardCardPile cardAt:CS_TOP]))
{
return YES;
}
return NO;
}
- removedPile:aCardPile from:discardCardPileView
{
id discardCardPile = [discardCardPileView cardPile];
id aCard;
if (maxIndex == 1) return self;
if ([recycleCardPile cardCount] != 0)
{
aCard = [recycleCardPile cardAt:CS_TOP];
[recycleCardPile removeCard:aCard];
[discardCardPile insertCard:aCard at:CS_BOTTOM];
[discardCardPileView display];
}
return self;
}
- getOffset:(float *) xOffset :(float *) yOffset forSize:(CardSize)aSize
{
if (aSize == CS_SMALL)
{
if (maxIndex == 1)
*xOffset = 0.5;
else
*xOffset = 15.0;
}
else
{
if (maxIndex == 1)
*xOffset = 0.5;
else
*xOffset = 20.0;
}
*yOffset = 0.0;
return self;
}
@end